import java.io.*;
import java.net.*;

public class Auth_android {
	private static String HOST = "https://www.google.com/accounts/ClientLogin";
	private static String EMAIL = "zisauction.com@gmail.com"; // 사용자 아이디
	private static String PASS = "zxcvbnm00"; // 비밀번호
	private static String SOURCE = "com.zisauction.mobileapp"; // 어플리케이션에 대한 간단한 설명

	public static void main(String[] args) throws Exception {
		try {
			System.out.println("START");
			StringBuffer postDataBuilder = new StringBuffer();
			postDataBuilder.append("Email=" + EMAIL);
			postDataBuilder.append("&Passwd=" + PASS);
			postDataBuilder.append("&accountType=HOSTED_OR_GOOGLE");
			postDataBuilder.append("&source=" + SOURCE);
			postDataBuilder.append("&service=ac2dm");

			byte[] postData = postDataBuilder.toString().getBytes("UTF8");
			URL url = new URL(HOST);
			System.out.println("MAKE URL");
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();System.out.println("Connection Success");
			conn.setDoOutput(true);
			conn.setUseCaches(false);
			conn.setRequestMethod("POST");
			conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
			conn.setRequestProperty("Content-Length", Integer.toString(postData.length));

			OutputStream out = conn.getOutputStream();
			out.write(postData);
			System.out.println("SEND!!");
			out.close();

			BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String inputLine;
			System.out.println("RECEIVED!");
			while ((inputLine = in.readLine()) != null) {
				System.out.println(inputLine);
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
	}
}
